------------------------------------------------------------------------------
--                                                                          --
--                  CairoAda - Ada95 binding for Cairo                      --
--                                                                          --
-- Copyright (C) 2006-2009, Damien Carbonne                                 --
--                                                                          --
-- This library is free software; you can redistribute it and/or modify it  --
-- under the terms of the GNU General Public License as published by the    --
-- Free Software Foundation; either version 2 of the License, or (at your   --
-- option) any later version.                                               --
--                                                                          --
-- This library is distributed in the hope that it will be useful,          --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of           --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details.                                         --
--                                                                          --
-- You should have received a copy of the GNU General Public License along  --
-- with this library; if not, write to the Free Software Foundation,        --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.           --
--                                                                          --
-- As a special exception, if other files instantiate generics from this    --
-- unit, or you link this unit with other files to produce an executable,   --
-- this unit does not by itself cause the resulting executable to be        --
-- covered by the GNU General Public License. This exception does not       --
-- however invalidate any other reasons why the executable file might be    --
-- covered by the GNU Public License.                                       --
------------------------------------------------------------------------------

--  FreeType platform-specific font interface.
--  The FreeType font backend is primarily used to render text on GNU/Linux
--  systems, but can be used on other platforms too.

--  Font Config functions not yet bound

with Cairo.Font_Face; use Cairo.Font_Face;
with Cairo.Scaled_Font; use Cairo.Scaled_Font;
with FT2.Base; use FT2.Base;

package Cairo.Font_Face.FT is

   pragma Elaborate_Body;

   function New_Font_Face (
      Face : FT_Face;
      Load_Flags : FT_Load_Flags := 0
      ) return Cairo_Font_Face_Handle;
   --  Creates a new font face for the FreeType font backend from a pre-opened
   --  FreeType face.
   --  This font can then be used with Set_Font_Face or New_Scaled_Font.
   --  The Cairo_Scaled_Font returned from New_Scaled_Font is also for the
   --  FreeType backend and can be used with functions such as Lock_Face.
   --  Note that Cairo may keep a reference to the FT_Face alive in a
   --  font-cache and the exact lifetime of the reference depends highly upon
   --  the exact usage pattern and is subject to external factors.
   --  You must not call Done_Face before the last reference to the
   --  Cairo_Font_Face has been dropped.

   procedure Lock_Face (
      Scaled_Font : in out Cairo_Scaled_Font'Class;
      Face : out FT_Face
      );
   --  Lock_Face gets the FT_Face object from a FreeType backend font and
   --  scales it appropriately for the font. You must release the face with
   --  Unlock_Face when you are done using it. Since the FT_Face object can
   --  be shared between multiple Cairo_Scaled_Font objects, you must not lock
   --  any other font objects until you unlock this one. A count is kept of the
   --  number of times Lock_Face is called. Unlock_Face must be called the same
   --  number of times.
   --
   --  You must be careful when using this function in a library or in a
   --  threaded application, because freetype's design makes it unsafe to call
   --  freetype functions simultaneously from multiple threads, (even if using
   --  distinct FT_Face objects). Because of this, application code that
   --  acquires an FT_Face object with this call must add it's own locking to
   --  protect any use of that object, (and which also must protect any other
   --  calls into cairo as almost any cairo function might result in a call
   --  into the freetype library).

   procedure Unlock_Face (
      Scaled_Font : in out Cairo_Scaled_Font'Class
      );
   --  Releases a face obtained with Lock_Face.

end Cairo.Font_Face.FT;
